package com.epmxx.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.epmxx.domain.Hotel;
import com.epmxx.service.HotelService;
import com.epmxx.mapper.HotelMapper;
import com.epmxx.vo.HotelVO;
import com.epmxx.vo.RoomQuery;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* 酒店业务接口实现类
*/
@Service
public class HotelServiceImpl extends ServiceImpl<HotelMapper, Hotel>
implements HotelService{

    @Autowired
    private HotelMapper hotelMapper;

    /**
     * 分页查询
     * @param query
     * @return
     */
    @Override
    public PageInfo<HotelVO> queryPage(RoomQuery query) {
        // 开启分页
        Page<HotelVO> data = PageHelper.startPage(query.getPage(), query.getLimit());
        this.hotelMapper.selectList(query);
        return data.toPageInfo();
    }

    /**
     * 新增酒店信息
     * @param hotel
     */
    @Override
    public void add(Hotel hotel) {
        this.hotelMapper.insert(hotel);
    }

    /**
     * 删除酒店
     * @param id
     */
    @Override
    public void delete(Integer id) {
        this.hotelMapper.deleteById(id);
    }

    /**
     * 修改酒店信息
     * @param hotel
     */
    @Override
    public void update(Hotel hotel) {
        this.hotelMapper.updateById(hotel);
    }

    /**
     * 批量删除
     * @param id
     * @return
     */
    @Override
    public int deleteHotelBatch(List<Integer> id) {
        return this.hotelMapper.deleteHotelBatch(id);
    }

}
